package it.softphone.commons.service.security;


import it.softphone.commons.service.ServiceObjectFactory;

import java.security.GeneralSecurityException;

import org.apache.commons.configuration.Configuration;

/**
 * 
 * @author softphone
 *
 */
public abstract class SecurityAccountServiceFactory {

	/**
	 * ignored 
	 * 
	 * @param cfg
	 */
	@Deprecated
	public static void setInitConfiguration( Configuration cfg ) {
	}
	
	/**
	 * use getSecurityAccountServiceFactory instead
	 * 
	 * @param conf
	 * @return
	 * @throws GeneralSecurityException
	 * @see {@link #getSecurityAccountServiceFactory()}
	 */
	@Deprecated
    public static synchronized SecurityAccountService getSecurityAccountService() throws java.security.GeneralSecurityException  {

		SecurityAccountServiceFactory factory = getSecurityAccountServiceFactory();

		return factory.newSecurityAccountService(null);

    } 

	/**
	 * 
	 * @return
	 * @throws java.security.GeneralSecurityException
	 */
	public static synchronized SecurityAccountServiceFactory getSecurityAccountServiceFactory() throws java.security.GeneralSecurityException  {
    	try {
    		
    		SecurityAccountServiceFactory factory = ServiceObjectFactory.getSPIService(SecurityAccountServiceFactory.class);

    		return factory;
    		
		} catch (Exception e) {
			throw new java.security.GeneralSecurityException(e);
		}
		
	}
  	
    public abstract SecurityAccountService newSecurityAccountService( Configuration cfg ) throws java.security.GeneralSecurityException;
    
}
